package com.eling.elcms.cater.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Indexed;

import javax.persistence.*;

/**
 * @author ZYJ
 * 菜品定价
 */

@Entity
@Table(name = "cate_dishprice")
@Indexed
public class DishPrice extends BaseModel {

	private static final long serialVersionUID = -4363916527482679438L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkDishPrice;
	
	
	/** 菜品 */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkDish")
	@In
	private Dish dish;
	
//	/**套餐*/
//	@OneToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "pkSetMeal")
//	private SetMeal setMeal;
	
	/** 单价*/
	@Column
	@Field
	private Double price;
	
	/** 定价类型*/
	@Enumerated(EnumType.STRING)
	@Field
	@In
	@FieldBridge(impl = EnumBridge.class)
	private PriceType priceType;
	
	@Version
	private Integer version;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum PriceType {
		Dish("菜品"),
		SetMeal("套餐");

		private String display;

		PriceType(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}

	public Long getPkDishPrice() {
		return pkDishPrice;
	}

	public void setPkDishPrice(Long pkDishPrice) {
		this.pkDishPrice = pkDishPrice;
	}

	public Dish getDish() {
		return dish;
	}

	public void setDish(Dish dish) {
		this.dish = dish;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public PriceType getPriceType() {
		return priceType;
	}

	public void setPriceType(PriceType priceType) {
		this.priceType = priceType;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
	
}
